home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 246 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: Dawn Koffman <dkoffman@cnj.digex.net>
  3. Newsgroups: comp.std.c++
  4. Subject: The type of the this pointer
  5. Date: 02 Feb 1996 19:31:30 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <199602022342.SAA23370@cnj.digex.net>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Fri, 2 Feb 1996 18:42:41 -0500
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBVAwUBMRLXOky4NqrwXLNJAQGKbAH9GlifM5Vad4vt4CljR6/FEnjmzE222HiB
  13.     iHqNwgp+zZMx0tGmhaQxH5GkM0nAbqgr+9oHPPl2aN/eG5RPCSAf3A==
  14.     =6gy9
  15. Originator: austern@isolde.mti.sgi.com
  16.  
  17. Question 1 
  18.  
  19. The ARM says:
  20.  
  21.     "The type of this in a member function of class X is X *const unless 
  22.      the member function is declared const or volatile; in those cases, 
  23.      the type of this is const X *const and volatile X *const, respectively."
  24.  
  25. 9.4.2 of the 4/95 draft standard says:
  26.  
  27.     "The type of this in a member function of class X is X*.  If the member
  28.      function is declared const, the type of this is const X*, if the member
  29.      function is declared volatile, the type of this is volatile X*, and
  30.      if the member function is declared const volatile, the type of this 
  31.      is const volatile X*."
  32.  
  33. Why has the type of this changed from X* const to X*, and from const X* const 
  34. to const X*?
  35.  
  36. Question 2
  37.  
  38. 9.4.2 of the draft standard goes on to say:
  39.  
  40.     "In a const member function, the object for which the function is called 
  41.      is accessed through a const access path; therefore, a const member 
  42.      function shall not modify the object and its non-static data members."
  43.  
  44. This section of the draft standard doesn't say anything to indicate that 
  45. mutable data members may be modified inside const member functions.  However,
  46. a simple example in D&E (page 287) seems to show that they may.  
  47.  
  48. Where in the draft standard is there an indication that mutable data members 
  49. _may_ be modified inside const member functions?  And, assuming they may, 
  50. what mechanism allows this, given that in a const member function the object 
  51. is accessed through a const access path?
  52. ---
  53. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  54.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  55.   in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  56.